﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

using ShootSearch.Core;
using ShootSearch.Spiders;
using ShootSearch.Util.Serializers;
using ShootSearch.Util;
using ShootSearch.Jobs;

using NUnit.Framework;


namespace ShootSearch.Tests
{
    [TestFixture]
    public class JobConfigTests
    {
        [Test]
        public void SerializeTest()
        {
            JobConfig job = new JobConfig(typeof(HttpSpiderJob));
            job.Name = "Job";
            //job.Type = new AssemblyConfig(typeof(HttpSpider));
            //job.Config = new HttpConfig();
            XmlFormatter.ToXmlFile(job,  IO.StartupPath + "\\xxxx.xml");
            JobConfig jc = XmlFormatter.FromFile(IO.StartupPath + "\\xxxx.xml", job.GetType()) as JobConfig;

            Assert.AreNotEqual(null, jc);
            Assert.AreEqual(job.Name, jc.Name);


            Regex regex = new Regex("(?<id>\\d+).*");
            Match m = regex.Match("213afdadf");
            Assert.AreEqual(true, m.Groups["id"].Success);
            Assert.AreEqual("213", m.Groups["id"].Value);
            Assert.AreEqual(true, m.Success);
            Assert.AreEqual("213afdadf", m.Value);



        }
    }
}
